import Mock from 'mockjs-async'
import { getBase64 } from "@/components/TiptapEditor/utils/index.js";

Mock.mock('/upload', 'post', function (opts) {
  const getBase64Async = async () => {
    // const { file, outFileType = 'base64' } = opts.body
    const file = opts.body.get('file')
    const outFileType = opts.body.get('outFileType') || 'base64'
    if (outFileType === 'base64') {
      return await getBase64(file)
    } else if (outFileType === 'url') {
      return URL.createObjectURL(file)
    }
  }
  return getBase64Async()
})